From a9c1da21e112a3b0672594fd9c247214a67af10b Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 26 Jul 2005 15:08:22 +0000 Subject: [PATCH] Fix testsuite to ignore tool/ dir. Signed-off-by: Rusty Russel Signed-off-by: Christian Limpach --- tools/xenstore/Makefile | 4 +- tools/xenstore/testsuite/02directory.sh | 15 ++-- tools/xenstore/testsuite/08transaction.sh | 90 ++++++++++++----------- tools/xenstore/testsuite/09domain.sh | 5 +- tools/xenstore/testsuite/12readonly.sh | 9 ++- tools/xenstore/xs_random.c | 6 ++ 6 files changed, 70 insertions(+), 59 deletions(-) diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile index 4419ebeeec..96c6909ec7 100644 --- a/tools/xenstore/Makefile +++ b/tools/xenstore/Makefile @@ -86,9 +86,9 @@ randomcheck: xs_random xenstored_test $(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED) stresstest: xs_stress xs_watch_stress xenstored_test - rm -rf $(TESTDIR)/store + rm -rf $(TESTDIR)/store $(TESTDIR)/transactions export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret - rm -rf $(TESTDIR)/store + rm -rf $(TESTDIR)/store $(TESTDIR)/transactions export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_watch_stress; ret=$$?; kill $$PID; exit $$ret xs_dom0_test: xs_dom0_test.o utils.o diff --git a/tools/xenstore/testsuite/02directory.sh b/tools/xenstore/testsuite/02directory.sh index f63ef1ff3d..f2b2401974 100644 --- a/tools/xenstore/testsuite/02directory.sh +++ b/tools/xenstore/testsuite/02directory.sh @@ -1,22 +1,23 @@ #! /bin/sh -# Root directory has nothing in it. -[ "`echo -e 'dir /' | ./xs_test 2>&1`" = "" ] +# Root directory has only tool dir in it. +[ "`echo -e 'dir /' | ./xs_test 2>&1`" = "tool" ] # Create a file. [ "`echo -e 'write /test create contents' | ./xs_test 2>&1`" = "" ] # Directory shows it. -[ "`echo -e 'dir /' | ./xs_test 2>&1`" = "test" ] +[ "`echo -e 'dir /' | ./xs_test 2>&1 | sort`" = "test +tool" ] # Make a new directory. [ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ] # Check it's there. -DIR="`echo -e 'dir /' | ./xs_test 2>&1`" -[ "$DIR" = "test -dir" ] || [ "$DIR" = "dir -test" ] +DIR="`echo -e 'dir /' | ./xs_test 2>&1 | sort`" +[ "$DIR" = "dir +test +tool" ] # Check it's empty. [ "`echo -e 'dir /dir' | ./xs_test 2>&1`" = "" ] diff --git a/tools/xenstore/testsuite/08transaction.sh b/tools/xenstore/testsuite/08transaction.sh index 86ea3ed4ae..c5311ed822 100644 --- a/tools/xenstore/testsuite/08transaction.sh +++ b/tools/xenstore/testsuite/08transaction.sh @@ -1,79 +1,81 @@ #! /bin/sh # Test transactions. +echo mkdir /test | ./xs_test + # Simple transaction: create a file inside transaction. -[ "`echo -e '1 start / -1 write /entry1 create contents -2 dir / -1 dir / +[ "`echo -e '1 start /test +1 write /test/entry1 create contents +2 dir /test +1 dir /test 1 commit -2 read /entry1' | ./xs_test`" = "1:entry1 +2 read /test/entry1' | ./xs_test`" = "1:entry1 2:contents" ] -echo rm /entry1 | ./xs_test +echo rm /test/entry1 | ./xs_test # Create a file and abort transaction. -[ "`echo -e '1 start / -1 write /entry1 create contents -2 dir / -1 dir / +[ "`echo -e '1 start /test +1 write /test/entry1 create contents +2 dir /test +1 dir /test 1 abort -2 dir /' | ./xs_test`" = "1:entry1" ] +2 dir /test' | ./xs_test`" = "1:entry1" ] -echo write /entry1 create contents | ./xs_test +echo write /test/entry1 create contents | ./xs_test # Delete in transaction, commit -[ "`echo -e '1 start / -1 rm /entry1 -2 dir / -1 dir / +[ "`echo -e '1 start /test +1 rm /test/entry1 +2 dir /test +1 dir /test 1 commit -2 dir /' | ./xs_test`" = "2:entry1" ] +2 dir /test' | ./xs_test`" = "2:entry1" ] # Delete in transaction, abort. -echo write /entry1 create contents | ./xs_test -[ "`echo -e '1 start / -1 rm /entry1 -2 dir / -1 dir / +echo write /test/entry1 create contents | ./xs_test +[ "`echo -e '1 start /test +1 rm /test/entry1 +2 dir /test +1 dir /test 1 abort -2 dir /' | ./xs_test`" = "2:entry1 +2 dir /test' | ./xs_test`" = "2:entry1 2:entry1" ] # Transactions can take as long as the want... -[ "`echo -e 'start / +[ "`echo -e 'start /test sleep 1 -rm /entry1 +rm /test/entry1 commit -dir /' | ./xs_test`" = "" ] +dir /test' | ./xs_test`" = "" ] # ... as long as noone is waiting. -[ "`echo -e '1 start / -2 mkdir /dir -1 mkdir /dir -1 dir / +[ "`echo -e '1 start /test +2 mkdir /test/dir +1 mkdir /test/dir +1 dir /test 1 commit' | ./xs_test 2>&1`" = "1:dir FATAL: 1: commit: Connection timed out" ] # Events inside transactions don't trigger watches until (successful) commit. -[ "`echo -e '1 watch / token 100 -2 start / -2 mkdir /dir/sub +[ "`echo -e '1 watch /test token 100 +2 start /test +2 mkdir /test/dir/sub 1 waitwatch' | ./xs_test 2>&1`" = "1:waitwatch timeout" ] -[ "`echo -e '1 watch / token 100 -2 start / -2 mkdir /dir/sub +[ "`echo -e '1 watch /test token 100 +2 start /test +2 mkdir /test/dir/sub 2 abort 1 waitwatch' | ./xs_test 2>&1`" = "1:waitwatch timeout" ] -[ "`echo -e '1 watch / token 100 -2 start / -2 mkdir /dir/sub +[ "`echo -e '1 watch /test token 100 +2 start /test +2 mkdir /test/dir/sub 2 commit 1 waitwatch -1 ackwatch token' | ./xs_test 2>&1`" = "1:/dir/sub:token" ] +1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/dir/sub:token" ] # Rm inside transaction works like rm outside: children get notified. -[ "`echo -e '1 watch /dir/sub token 100 -2 start / -2 rm /dir +[ "`echo -e '1 watch /test/dir/sub token 100 +2 start /test +2 rm /test/dir 2 commit 1 waitwatch -1 ackwatch token' | ./xs_test 2>&1`" = "1:/dir/sub:token" ] +1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/dir/sub:token" ] diff --git a/tools/xenstore/testsuite/09domain.sh b/tools/xenstore/testsuite/09domain.sh index 9208dda0ec..f0a983e6fd 100644 --- a/tools/xenstore/testsuite/09domain.sh +++ b/tools/xenstore/testsuite/09domain.sh @@ -4,8 +4,9 @@ # Create a domain, write an entry. [ "`echo -e 'introduce 1 100 7 /my/home 1 write /entry1 create contents -dir /' | ./xs_test 2>&1`" = "handle is 1 -entry1" ] +dir /' | ./xs_test 2>&1 | sort`" = "entry1 +handle is 1 +tool" ] # Release that domain. [ "`echo -e 'release 1' | ./xs_test`" = "" ] diff --git a/tools/xenstore/testsuite/12readonly.sh b/tools/xenstore/testsuite/12readonly.sh index 336960ffac..bfe6273fe1 100644 --- a/tools/xenstore/testsuite/12readonly.sh +++ b/tools/xenstore/testsuite/12readonly.sh @@ -4,16 +4,17 @@ [ "`echo 'write /test create contents' | ./xs_test 2>&1`" = "" ] # These are all valid. -[ "`echo 'dir / -read /test +[ "`echo dir / | ./xs_test --readonly 2>&1 | sort`" = "test +tool" ] + +[ "`echo 'read /test getperm /test watch /test token 0 unwatch /test token start / commit start / -abort' | ./xs_test --readonly 2>&1`" = "test -contents +abort' | ./xs_test --readonly 2>&1`" = "contents 0 READ" ] # These don't work diff --git a/tools/xenstore/xs_random.c b/tools/xenstore/xs_random.c index 8646137ca4..c835a40bf3 100644 --- a/tools/xenstore/xs_random.c +++ b/tools/xenstore/xs_random.c @@ -987,6 +987,8 @@ static void setup_file_ops(const char *dir) char *cmd = talloc_asprintf(NULL, "echo -n r0 > %s/.perms", dir); if (mkdir(dir, 0700) != 0) barf_perror("Creating directory %s", dir); + if (mkdir(talloc_asprintf(cmd, "%s/tool", dir), 0700) != 0) + barf_perror("Creating directory %s/tool", dir); do_command(cmd); talloc_free(cmd); } @@ -1211,6 +1213,10 @@ static bool ops_equal(struct ops *a, void *ah, char *nodename; bool ret = false; + /* Ignore tool/ dir. */ + if (streq(node, "/tool")) + return true; + /* FILE backend expects talloc'ed pointer. */ nodename = talloc_strdup(NULL, node); permsa = a->get_perms(ah, nodename, &numpermsa); -- 2.30.2